﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace KATS_Client.UI
{
    public partial class AuthenticationDetails : Form
    {
        public AuthenticationDetails()
        {
            InitializeComponent();
            password_textBox.Text = Client.User.Password;
            username_textBox.Text = Client.User.Username;
            error_label.Text = "";
        }
        

        private void button1_Click(object sender, EventArgs e)
        {
            this.Hide();
        }

        private void saveButton_Click(object sender, EventArgs e)
        {
            string username = username_textBox.Text;
            string password = password_textBox.Text;

            if (username == string.Empty)
            {
                // error message
                error_label.Text = "Username cannot be empty";
            }
            else if (password == string.Empty)
            {
                error_label.Text = "Password cannot be empty";
            }
            else
            {
                // save this
                this.Hide();
                Client.User.Update(username, password);
                Client.ServerConnection.MakeNewMainConnection();
            }
        }

    }
}
